package chapter5.extend;

/**
 * 有继承关系的类在构造子类对象时，总是会先实例化父类对象
 */
public class Creature {
    public Creature() {
        System.out.println("Creature无参构造");
    }

    public static void main(String[] args) {
        new Wolf();
    }
}

class Animal extends Creature{
    public Animal(String name) {
        System.out.println("Animal带一个参数的构造器,动物的名字为:" + name);
    }

    public Animal(String name, int age) {
        this(name);
        System.out.println("Animal带两个参数的构造器,其age为:" + age);
    }
}

class Wolf extends Animal {
    public Wolf() {
        super("灰太狼", 3);
        System.out.println("Wolf的无参构造");
    }
}
